package com.example.coursehub.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;

import java.io.Serializable;
import java.util.Objects;

@Getter
@Setter
@Embeddable
@NoArgsConstructor
public class FavoriteQuestionBankQuestionId implements Serializable {
    private static final long serialVersionUID = 5378427258154681197L;
    @Column(name = "favorite_question_bank_id", nullable = false, length = 100)
    private String favoriteQuestionBankId;

    @Column(name = "question_id", nullable = false, length = 100)
    private String questionId;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        FavoriteQuestionBankQuestionId entity = (FavoriteQuestionBankQuestionId) o;
        return Objects.equals(this.questionId, entity.questionId) &&
                Objects.equals(this.favoriteQuestionBankId, entity.favoriteQuestionBankId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(questionId, favoriteQuestionBankId);
    }
    public FavoriteQuestionBankQuestionId(String favoriteQuestionBankId, String questionId) {
        this.favoriteQuestionBankId = favoriteQuestionBankId;
        this.questionId = questionId;
    }
}